//
//  MatchDetailViewController.m
//  video
//
//  Created by lanou3g on 15/5/26.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "MatchDetailViewController.h"

@interface MatchDetailViewController ()

@end

@implementation MatchDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
        [self layout];
    self.player.contentURL=[NSURL URLWithString:self.match.video_addr];
    [self.player play];
    self.searcTextField.delegate=self;

}
-(void)back:(UIBarButtonItem*)BI{
    [self.navigationController popViewControllerAnimated:YES];

}
-(void)layout{
    UIColor *color=[UIColor colorWithRed:236/255.0 green:246/255.0 blue:221/255.0 alpha:1];
    self.view.backgroundColor=color;
    
    [self.searchButton setBackgroundImage:[UIImage imageNamed:@"search"] forState:normal];
    
    self.player=[[MPMoviePlayerController alloc]init];
    [self.playerView addSubview:self.player.view];
    NSLayoutConstraint *playerLeft=[NSLayoutConstraint constraintWithItem:self.player.view attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.playerView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0];
    
    NSLayoutConstraint *playerTop=[NSLayoutConstraint constraintWithItem:self.player.view attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.playerView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
    
    NSLayoutConstraint *playerRight=[NSLayoutConstraint constraintWithItem:self.player.view attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.playerView attribute:NSLayoutAttributeRight multiplier:1.0 constant:0];
    NSLayoutConstraint *playerBottom=[NSLayoutConstraint constraintWithItem:self.player.view attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.playerView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0];
    [self.playerView addConstraints:@[playerLeft,playerRight,playerTop,playerBottom]];
    
    self.player.view.translatesAutoresizingMaskIntoConstraints=NO;
    


    
    
        UIBarButtonItem*leftBI=[[UIBarButtonItem alloc]initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:self action:@selector(back:)];
    self.navigationItem.leftBarButtonItem=leftBI;
    leftBI.tintColor=[UIColor yellowColor];//字体颜色
    [self setContent];
   
}
//设置内容
-(void)setContent{
    self.matchName.text=self.match.name;
   
    self.matchName.numberOfLines=0;
    self.updateDate.text=self.match.update_time;
    
    self.playCount.text=[NSString stringWithFormat:@"%d",self.match.play_count];

    self.score.text=[NSString stringWithFormat:@"%d",self.match.score] ;


}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{


    [self.searcTextField resignFirstResponder];
}
- (IBAction)praise:(id)sender {
   
   
}
- (IBAction)search:(id)sender {
    SearchViewController*SVC=[[SearchViewController alloc]init];
    SVC.str=self.searcTextField.text;
    
    [self.navigationController pushViewController:SVC animated:YES];
    
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
    [self.searcTextField resignFirstResponder];
    return YES;

}



@end
